You’re taking that verse out of context. This verse is addressing those who are married, looking at someone with lustful intent, and saying that avoiding physical actions isn’t enough to satisfy the intent behind God’s commandment not to commit adultry.
Jesus doesn’t mean you should literally kill yourself.