I am animating a Rubik's cube, and as soon as I get to the second rotation the blocks that have previously been rotated start tripping out even though it should have been reset. I tried making the graph linear which fixed a lagging issue I had, but the blocks still start to spin instead of rotating around a single axis.
All the small cubes of the Rubik's cube need to have their origin on the exact same point and it needs to be in the middle of the Rubik's cube. Also, when you've rotated and keyframed a face and its 6 cubes, make sure that you've also keyframed all the other cubes even if they are still, otherwise they will interpolate between other keyframes you've created for them and you may not want that.
In addition to the details provided by moonboots, use quaternion rotation mode instead of Euler. This can be set in properties/object/transform. And be careful of auto-handles; recommended is to use vector handles, set in the graph editor.
Euler rotations do not describe "shortest path" rotations; they have torque, and they have the greatest torque at 90 degree rotations. Quaternions are shortest path rotations, at least when treated as indivisible 4D vectors, but Blender's implementation, interpolating components and then normalizing afterwards, can leave you with errors with autohandles.
Edit: Downvote is probably from somebody doubting this. Here's a file demonstrating the problems from using either Euler angles or autohandle quaternions, side by side with vector handle quaternions working properly, with a 60 frame animation: