Why do we say a robotic arm has 2 degrees of freedom even though the two joints rotate along the same axis? Why isn't it called a 1 dof robot?
The degrees of freedom of a serial manipulator equals its number of joints. A more general definition can be found on Wikipedia. It is about being able to describe the state (configuration) of the robot (in terms of position) and the length of the vector required to describe the configuration. For a serial kinematic chain the length of the vector equals the number of joints. Even when the setup is redundant, the objective is not to express the pose of the final frame (tool center point or end effector), but the robot itself.
The number of degrees of freedom any mechanism has (including a robot) is solely based on how many different ways there are to change its configuration (the position and orientation of every part of the system).
In the case of a robot arm with two joints, you can change its configuration in two different ways (by moving each joint) so it is said to have two degrees of freedom.