Finally getting back to this, sorry for the delay.
It looks like the issue is that you have a line break after the suffix $$
in the second example.
This works:
You may want to see the discussion here on blocks and $$
use:
https://forum.obsidian.md/t/block-reference-for-multiple-paragraph/7674