I think what is going on is that in all cases, the Python file is read from top to bottom. For function definitions, this doesn't matter because the function calls are not actually instantiated during the definition.
However, when calling a class constructor 'MyFirstClass' to define a class level attribute of 'MySecondClass', an attribute which will be integral to the definition of the class itself, then necessarily 'MyFirstClass' must be defined, because it must be instantiated at the moment of definition of the class, as opposed to being instantiated later, e.g., during later call from a method.