It's important to figure out the root cause(s) in this situation, but there's not enough information here to do so.
If you don't figure out the first thing to have gone wrong, it's likely to repeat. The dropout is going to remain at least a little bit compromised here no matter what you do. The goal is to get to an outcome where it won't be compromised by a critical amount and things can function normally, but since any amount of slippage will chew up the dropout more, you have to do everything possible to make that not happen, which means figuring out why it happened in the first place. It can also make it difficult to tension the chain correctly.
Shimano IGH axle nuts absolutely need their proper lubrication and torque, especially on aluminum dropouts. (Lubrication of the threads is critical for thread preload). It's likely but not knowable with the information given that sometime early on in the bike's life, perhaps when initially built, the DS axle nut was ridden with inadequate thread preload and some movement occurred. This can in turn wallow out and erode the surface on the dropout, creating a divot, depression, or otherwise making the contact surface uneven. This can happen fairly quickly on aluminum frames. Once that's true, the hub can have trouble ever staying properly in place again.
Playing games with putting the technically wrong keyed washers on a Shimano IGH hub is an eyebrow-raising idea unless done for very specific reasons. I can imagine only one here: getting the hub all the way forward in the dropout, so that it contacts an undamaged or less-damaged surface, and then using a different pair of washers so the tabs can sit behind the axle while still positioning the cassette joint in an acceptable fashion for the cable routing. One of the potential fixes here, if in fact the root issue is damage to the dropout surface, is to half-link the chain, slightly altering the zone the locknut surfaces land in naturally, so that you can clamp to a previously unused section of dropout, which could then necessitate doing something like this with an unorthodox pair of keyed washers subbed in. It's often the case that a given bike with a given tooth count combination doesn't have one full link worth of adjustment to do such a thing, but can do it with a half-link.
For the most part, there is no such thing as welding-level dropout repairs on an aluminum frame, other than the relatively uncommon case of ones where everything is an alloy that doesn't require post-weld heat treatment. It's possible to imagine a framebuilder-level cold fix here that involves smoothing down the area and bonding on a thin steel surface that sandwiches the dropout and provides a surface for the nuts to tighten against. Some bikes do come with such a thing stock to prevent similar issues to what you've experienced, and mid-drive aluminum IGH bikes are something like the most appropriate place imaginable to do this.
Shimano IGH axle nuts can be a little finicky at the best of times and sometimes need replacing. They work, but the hardened and flatted axle design sometimes cuts into them and wallows out the threads, especially if they were under-lubricated or unlubricated. If by not being able to hold the wheel tightly enough you mean you get the sense it's on the way to stripping or otherwise doesn't feel solid when tightened, replace it.
Edit in response to pictures: It looks like the serrations on the hub locknuts are worn down to nothing. That, or they're full of aluminum from being able to twist against the frame. Either way they won't do their job properly and should be addressed, either by replacing them or digging out the former dropout material as applicable.
To lubricate the hub axle nuts, use grease or anti-seize.
This frame has what the chart refers to as "standard" dropouts. "Reverse" is backwards-opening, a.k.a. track dropouts. So depending on the angle, either the "7R/7L" or "5R/5L" combination is the correct one. What this really controls is the angle the cassette joint lands at, which in turn keeps the housing stop land at the correct place at the correct angle.
It's likely that the first thing to have gone wrong is the hub was allowed to twist in the frame from the axle nuts being undertightened, which then chewed a notch into the dropout from the anti-rotation washer bearing against it too hard for too long (easy to imagine on a mid-drive). The notched area will now likely have a hard time playing correctly with the anti-rotation washers no matter what you do. I think a good plan here would be see what chain length tricks you can employ to have the anti-rotation tab avoid landing against the notch, and also start with fresh locknuts and axle nuts, properly greased and torqued. I don't know of any other more sophisticated parts you could add to prevent rotation; there are a lot of similar bikes out there that get by without such a thing, so hopefully yours can too.
There's not an image of the inside surface of the dropouts, where the locknuts contact. Note if there's a divot or otherwise heavily mangled spot where the slippage/spin occurred (and there presumably is from looking at the locknut serrations), the hub will tend to have a hard time staying locked against that surface no matter what you do. This is a further reason to pursue chain length tricks.
To be clear, one of the likelier ways of doing this is to use a half-link to get the locknut contact position to an area that wouldn't otherwise be achievable. The other options are take away a whole link or change the gear combination. A half-link looks like this: