why motor continues to rotate in same direction even after changing the polarity of both armature as well as field winding?
Imagine two electromagnets on the table in front of you.  You put one of the ends of each near the other.  You set the polarity of currents thru them so that one of them makes N and the other S.  They clink together.  You flip both currents and now instead of N and S you get S and N.  You still have two opposite polarities attracting. Clink.

Now if you only flip one of the currents, then you have either N-N or S-S.  Just like it didn't matter whether you had N-S or S-N, this time the two magnets will push away.  Flip both polarities again, and they still push away.

Motors work on the same principle.  You flip the polarity of one of the rotor or stator, and the motor will go the other way.  You flip both, and there is no difference.  What used to be N in the rotor attacted to S in the stator is now S in the rotor but still attracted to N in the stator.  Repulsion works the same way.  What was S-S is now N-N, but either way they still push apart, which in this case means rotate in the same direction.