In the bedtime shema, some siddurim have the bracha of Hamapil printed immediately before the paragraph of shema, whereas others have it printed at the very end of the bedtime shema prayers. What is the reason for each practice? Are there specific communities that have a minhag to do one or the other?
The minhag to say Hamapil at the end is so the beracha is semucha to (just before) sleep. That is that there should be no hefsek (break) between the beracha and falling asleep.
The minhag held by the Gra and other achronim is to say Hamapil first. They reason that the psukim said afterwards are not considered a hefsek.
I am basing what I wrote on Siddur Vilna (Mesores) page 245.
I'll add from memory that it is considered good to fall asleep while saying psukim. If you were to say Hamapil at the end, well, you might not ever make it ...
all sidurim I saw bring the beracha just before shema, but I'm sefaradi, and while I used many different sidurim for kiriat shema al hamita all of them were for edut hamizrah.
maybe if you pay attention to which sidurim are like this and which like that you could answer your own question
Nusach Ari (Chabad) has Hamapil at the end of Kriyas Shema Al Hamita