「彼(かれ)らは、横(よこ)になりながら 話(はな)した。」
ながら is used with 'verb stem (which is ます form without ます)'
So in this case, よこになる is to lay down(literal meaning is 'to become sideway') and ます form is よこになります, remove ます and add ながら instead to add meaning of 'while ...ing'
To give you few more examples,
私(わたし)は音楽( おんがく)を 聞き(きき)ながら はしった。
I ran while listening to music.
きく→ききます→ききながら
私は テレビを 見(み)ながら ご飯(はん)を 食(た)べる。
I eat meal while watching TV.
みる→みます→みながら
I hope this helps :)