I understand that 12/8 can be counted as 4/4 time where each beat gets a triplet but I don't understand why some songs that seem apt for 12/8 still get written out in 4/4. What are the criteria for which gets chosen?
And why is 4/4 sometimes used for music apparently in 12/8?
Here's a classic example. Written in 4/4 (well, 2/2 'cut time' actually, but let that go for now) rather than 12/8. Beethoven has chosen the time signature that suits the melody with its dotted 8th - 16th rhythms rather than the accompaniment with its (LOTS of) 3-groups.
and here are two approaches to notating a shuffle (NOT swing - just for once that 'metric modulation' 8th = triplet notation is accurate) tune.
(Publishers usually go with the 12/8 option for 'Blueberry Hill, perhaps someone thought that too 'hard' for guitarists?):
Most likely ease of writing, and ease of reading. In 4/4 it needs to be stated that each crotchet is to be treated as 3 quaver triplets, which then can give the piece a swing feel, instead of a straight eight feel. Swing is roughly (sometimes exactly!) the first two quavers tied, followed by the third. I call it the 'Humpty Dumpty' rhythm.
So, unless the piece has specifically lots of separate quavers, amounting to 12/8, it's written in 4/4 with a note at the top.
Some songs with a triplet/shuffle in 4/4 are written in 12/8 for ease of notation/reading but sometimes the notation in 12/8 will not allow for all the notes to be written this way so 4/4 must be used and all the triplets notated individually.
There isn't really a formula for this. It is up to the composer to write in such a way that makes sense to them and, ideally, would be easy for a performer to read. The choice will likely depend on the tempo of the piece. To quote Paulson & Cheyette:
"Composers do not always write in the meters best adapted to the speed or tempo of their compositions, but rely on the performer's sense of rhythm and interpretation."