How does the filter post_updated_messages work?

When a new function has a parameter, the parameter has to be passed
when the function is called right? In the case above, how does WP know
that $messages is in fact, $messages from WP?

If it is a WordPress hook (you can add your own) running in its normal context (you can run filters anywhere if you want) then WordPress calls the function when apply_filters('hook-name', ....) runs. The parameters are passed in at that time so WordPress has control of it. It is possible to run apply_filters yourself though why you would ever need to do that with post messages I don’t know. Applying the_content filters is probably pretty common, so for example:

// data from some external source
$data = get_my_external_content();
$data = apply_filters('the_content',$data);

Now you’ve passed your own data through that filter. Again, the parameter is passed when apply_filters runs.

Sorry for being totally unrelated to the context above, but why does
var_dump($post_updated_messages); return null to me. I want to see
what’s inside.

post_updated_messages is a hook name, not a variable you can dump. Inside your callback var_dump($messages) will give you what you have to work with.

If you want to see the filters and callbacks try var_dump($GLOBALS['wp_filter']);. That is an enormous array. Be warned. Not everything will show up, though. It depends on context and on what filters have and haven’t been added.