The same things that give onions their unique flavor—sulfur compounds—are responsible for why you cry when chopping them up. According to this video from Reactions, slicing an onion breaks open onion cells and releases chemicals that transform the sulfur compounds into a gas. This gas irritates the nerves in your eyes, making them water.
To avoid the waterworks, you can wear goggles while you cook. But if you're not a fan of the whole chemistry-lab look (you do you), simply refrigerate your onions before slicing and dicing. Cold reduces the tendency of the compounds to turn into a gas, which will minimize that burning sensation.