Some learn over time by picking up rudimentary theory online, from hard-copy books, or with teachers. You can also learn over time by going through graded accordion instruction either with a teacher or on your own, using a graded materials such as the Palmer-Hughes accordion course books.
You can also help yourself learn by finding a lead sheet or sheet music to the piece or tune that is marked with chords. The chord marks are often inserted for accompaniment instruments like guitar or whatev. You can use those chords as pointers for which accordion basses to use.
If the song or tune is not super complex, much of the time it will be just as noted in the comment above, some combination of I, IV, V, V7, or minor variants thereof. Or diminished or augmented chords where they fit. For example, basses for a hefty a percentage of standard Christmas carols can be worked out literally using just these chords, and often only two or three of these chords. Advanced players might arrange carols with all kinds of jazz "Sus" chords and minor sevenths and colored modulations, and all that snazzy stuff. But you can totally carry the day with good old I, IV, V7 a helluva lot of the time.