I was searching for a simulation that could help illustrate, but so far just found one simple simulation (but brief) showing how when there are more than 2 bodies interacting gravitationally, then a body can be flung in a new direction that is unlike the predominate old direction of the group of bodies before the momentum transfer. In short, you can have a net momentum in one direction, the total momentum of the bodies, and they can initially all be going in that direction, such as orbiting the galactic center in 1 direction, and then get the near approach involving more than 2 bodies and get 1 of the bodies flung off in a new direction. The net momentum of all the bodies is conserved. If 1 is flung in a near opposite direction, the remaining have more velocity in their original direction to conserve the momentum. Also, any star can be torn apart by a close interaction with a dense massive object (such as neutron star or black hole, of which any galaxy will have very many). So, you can easily get gas then moving in a new direction.
Example of a chaotic 3-body interaction: