How does it get out of alignment?
There are many ways and all it needs is for a bolt not to be tightened correctly.
The other thing is that gears are setup with the bike on a stand and as soon as the rider sits on it, the frame slightly distorts or, in my case, distorts considerably.
Cable tension adjustment is often a matter of a quarter or half turn by the way. When you are new to it, you tend to turn them 3 or 4 turns.
But, if its under warranty, take it back. You wouldn't be the first to buy something with a bent component so save yourself the grief.