How to animate a cube pivoting more than once without affecting it's original position
One way is to do this with help of empties. to parent them one after one:

For example, in the GIF below, D (the cube) is parented to empty C; C is parented to B; B is parented to A, which is the top-level parent here ("great-grandfather" :P). Then, insert keyframe for C, B and A in turn.

By using this method, the hierachy should be well planned before parenting, based on the expected rotation orders.



You may also want to replace the empties with armature of bones. You can see the hierachy better in this way since bones have head and tails, though a bit more complicated.

P.S.: For a pivot-switchable animation like this(especially with rotations), which can be really tricky, you have to find a way to control the pivots (better to be "pivot objects") to have them in position in time.