giving people with mental illnesses a pass

okay im sorry if i sound ignorant or uneducated because i am. which is why im trynna get an explanation from someone.

so im confused about how we justify people behaviors because of their mental illnesses. like i get some people act that way because of them but idk if i can give people a pass when theyre a shitty person towards me just because theyre mentally ill or have some sort of disorder.

like who do we give a pass to and who do we not? (sorry if that sounds like a dumb question i just dont know how to word most of this stuff).

and as im writing this i thought about how there is shooters who didnt go to jail because they were labeled as mentally ill even tho they literally took a human life? but then there's others werent given a pass and were sent to prison, although i think thats a race thing (correct me if im wrong because im uneducated in that topic too and am only going from what ive heard in the media).

anyways can someone explain all this to me? sorry if it was all badly worded, i really dont mean to offend anyone.