In general when using Markdown (and extensions to it like block IDs) it’s best to put blank lines between different kinds of things. Sometimes its required, and even when it’s not it tends to eliminate surprising behavior.
Moved to Help for not following the bug report template and because while block linking could be improved, this isn’t a bug as such. There may be feature requests about this that you can upvote; if not, you could post one.