Database version: 3.2.11
Exact steps to cause this issue:
Tagged one of our users with this username: _MILAD_
I expected to see user's name linked with his account page.
I just saw his name only, the word is not linked with account page!

Why this happens? how can we solve this?
Do we have any rules and restrictions for selecting usernames?
Seems like markdown plugin is processing the text before the mentions plugin. Maybe increasing the priority of the filter:parse.post hook in mentions would fix this.
Might be related to the username... _MILAD_. Can you share the link to his account profile on your forum @mohammadhassan99 ?
@julianlam Yes of course: https://forum.sanatisharif.ir/user/_milad_
Does the mention work with @milad or @-milad?
@julianlam

Okay, thanks, I will try to reproduce on my end.
Looks like we may have to disallow use of _ in slugs, I've made the change in #6133, will merge if tests pass...
disallow use of _ in slugs
This restriction is just a workaround. Discourse allow underscore, so do you. string after @ should be handled out of markdown (or any markup language) context.
The development of logic to handle the @ sign followed by underscore requires more research than I can do at the moment. Feel free to try it out and submit a PR, but I'm not too familiar with building markdown-it plugins.
Most helpful comment
Looks like we may have to disallow use of
_in slugs, I've made the change in #6133, will merge if tests pass...