"moodleform_mod" is a class that inherits from class "moodleform".
The "moodleform" class, has a member variable called $_form, that is an instance of the "MoodleQuickForm" class, which inherits from "HTMLQuickForm".
The outer "moodleform" class handles general functionality such as the get_data() and set_data() calls, whereas the "MoodleQuickForm" class handles the internal details of each of the elements within the form.
Inside the "definition()" function, you generally use $mform as a reference to the internal $_form member (i.e. $mform is an instance of "MoodleQuickForm").
So, inside the "definition()" function, you can call $this->set_data(), as that is calling the function defined in the "moodleform" class - you can't call $mform->set_data(), because the "MoodlQuickForm" class has no "set_data()" function defined.