All perfect praise be to Allaah, The Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad is His slave and Messenger.
Your prayer is valid, and you are not required to do anything. Straightening the rows is recommended according to the view of the majority of the scholars, and the prayer is not invalidated because of not straightening the rows.
Nonetheless, we recommend that you be keen to straighten the rows in the future because it is a Sunnah to straighten the rows in congregational prayer, in a way that your foot is aligned with the foot of the person standing next to you and your shoulders are aligned as well.
There are many ahaadeeth that recommend this, among which is the hadeeth of An-Nu’maan ibn Basheer, who said, “The Prophet said, 'Straighten your rows, otherwise Allaah will create dissension amongst you.'” [Al-Bukhari and Muslim]
Also, Anas ibn Maalik narrated that the Prophet said, “Straighten your rows, for I see you from behind my back.” Anas added, “Everyone of us used to stick his shoulder to the shoulder of his companion (i.e. the person standing next to him) and his foot to the foot of his companion.” [Al-Bukhari]
Besides, Anas ibn Maalik, narrated that the Prophet said, “Straighten your rows, and stand close to each other in your rows, bring them close to one another. By the one in whose hand is my soul, I can see the devil passing through the gaps in the rows like the hathaf (a bunch of small black sheep).” [Abu Daawood, an-Nasaa’i - Ibn Hibbaan graded it saheeh (sound)]
Allaah knows best.