Basically if you assign some member in nn.Module the internal __setattr__ method is called.
Have a look at the source code 19.
Based on the type you try to assign, the conditions call the appropriate method to register the parameter or buffer etc.