Thanks for the help.
The strange movements in the X and Y stopped and the Y axis goes for a second pass like it should be.
; homex.g
; called to home the X axis
;
; generated by RepRapFirmware Configuration Tool v2.1.3 on Thu Nov 28 2019 16:04:13 GMT+0000 (Hora padrão da Europa Ocidental)
G91 ; relative positioning
G1 H2 Z0.5 F6000 ; lift Z relative to current position
G1 H1 X-295 F1800 ; move quickly to X axis endstop and stop there (first pass)
G1 X5 F6000 ; go back a few mm
G1 H1 X-295 F360 ; move slowly to X axis endstop once more (second pass)
G1 H2 Z-0.5 F6000 ; lower Z again
G90 ; absolute positioning
; homey.g
; called to home the Y axis
;
; generated by RepRapFirmware Configuration Tool v2.1.3 on Thu Nov 28 2019 16:04:13 GMT+0000 (Hora padrão da Europa Ocidental)
G91 ; relative positioning
G1 H2 Z0.5 F6000 ; lift Z relative to current position
G1 H1 Y-315 F1800 ; move quickly to Y axis endstop and stop there (first pass)
G1 Y5 F6000 ; go back a few mm
G1 H1 Y-315 F360 ; move slowly to Y axis endstop once more (second pass)
G1 H2 Z-0.5 F6000 ; lower Z again
G90 ; absolute positioning