You are correct! Your solution works correctly!
I have identified what was happening and here is what is happening:
All block event actions are converted to 'C' code, which are then compiled in memory. And this compiled code is invoked to perform the event action. This is done to speed up the simulation. By adding a call to "coder.extrinsic('rand')" you are specifying that the MATLAB action method should call the interpreted MATLAB method rand, instead of the code-generated method. Therefore the seeds are now in sync with what is set on the MATLAB command prompt. And the reason you need to initialize val is because, to generate the 'C' code, the return type of the call to the external rand function cannot be inferred. By setting val = 1 (or any double value), you are letting the code generation know the type of val (as double).
I have identitied the problem in the code I have posted above, which was the source of my confusion. I added the following in the block:
disp(['seed: ' num2str(r.Seed)]);
But missed adding coder.extrinsic('rng').