Yes, sometimes we do need to lock people up in mental institutions. The case in question where a police officer in Ohio used a syringe to squirt semen on women at a Walmart store is a prime example of an instance where involuntary commitment in a mental institution would be helpful to society.
There are people who do terrible things because they are terrible people. There are others who do not know better. When a person's behavior makes them hurt others, it's important to put the person into a mental institution. If they cannot control themselves it is important that they do not hurt others.
Yes, if someone goes to the trouble to plan an attack by putting their body fluids into a syringe, they should face jail time or go to an institution. Someone who performs such disrespectful acts is probably not in their right mind and should not be free to risk the health and welfare of others.
Some people need to be locked up and in mental instutions for thier safety and the safety of others. But the majority of people, including people who think that they are mentally healthy need better access to mental health care. We do not take enough care of our mental health.