Kindly reference the following link(s):
Forming a second row instead of filling gaps in the first (in congregation) | Sheikh Assim Al Hakeem
Can I move forward while praying in congregation if I see a gap in the front row?
Can I walk in prayer, go left, right or go front or back when an empty space opens up