That is the same principle when you pull a trailer with FWD or RWD and the back of the trailer wants to pass in front,
DO NOT BRAKE or you will make it worse, accelerate and it will come back straight.
It is a bit tricky if the situation wants you to stop, so you may use the brakes as soon as the trailer is in line.
The safe way: Have independent brakes installed on your trailer (see Topic f5 -Towing in case you missed it)