The thing is against Mario is that you also can play the patient game against them: One of you will approach eventually. Mario has Fireballs to attempt to rack up damage, but getting used to powershielding Fireballs will help greatly. Spotdodging any grab attempts then charging a Down Smash predicting them to spotdodge any attack you throw out usually stuffs them away. Down Tilt and Up Tilt also can keep Mario away as they are light, moderate knockback attacks which can poke aggressive players. Forward Tilt and Jab also beat out Fireballs priority-wise, so you can do that if they try to play defensively.
For the whole edgeguarding thing, airdodge once you get near the ledge then use Up B/Side B if necessary. If they will cape, you will have a few frames to air dodge beforehand. If you know they are going to cape, Side B away from the stage so the cape will make them get hit as a result. You can also airdodge the first few bits of Mario's FLUDD, and Marios often follow up FLUDD with a FAir or the Cape. Predict this, and airdodge as necessary or Counter if you feel ballsy as all living hell.
And to prevent the middle scenario, just don't get grabbed at all. Keep up pressure with tilts and Down tilted FSmashes, and Side B at necessary times when the Mario uses Up Smash. Do not approach them when they charge up a smash attack predicting a roll, instead walk right out of their range and charge your own upwards tilted FSmash. As long as they can't get you offstage, they can't use any edgeguarding tools.
Hope this helps alot!