It depends on which direction you want to do.
@timl gave a good suggestion for the form.
However, (not his solutions issue), when you go back, your Gallery is selecting the incorrect record, which means your .Selected (and if you have anything highlighted to show it's the one selected), it will not show the correct one selected (if it does that's a whole other bug then).
Which means, I would also use the variable to re-select the correct row in the Gallery. Essentially this way your form can keep the .Selected and just keep the gallery on the correct record, but there is zero harm in using the Global in both places either.
You can also use a local context record on the Gallery (same as timl said) but as a Context value, then use the Navigate to Pass the value to the Form and use that.
All of the options will work, I was just curious if you needed the gallery to stay on the record you selected to Edit, so the user experience is, oh crud I scrolled down 30 records, clicked, came back now the first (or last) row is selected let me go find my record again.
I will also add one last thing. Since we don't know if you are applying filtering etc in your Gallery items it "may" have an impact on the answer (not to get the data to the form) but reselecting the write row, if for any reason the filters are resetting.
If these suggestions help resolve your issue, Please consider Marking the answer as such and also maybe a like.
Thank you!
Sincerely, Michael Gernaey