Don't over oil the filter if you're running a K&N (or any oiled air filter) and you have a hot wire MAF. Excess oil from the filter can get on the wire and cause issues. A normally oiled filter won't cause any problems, but I've seen a few folks get caught out by the if-a-little-is good-then-more-is-better approach to oiling the filter. Also, make sure it's all dry before you start the car or the same thing will happen. You're lucky you have a CANBUS port to trouble shoot. It should tell you if there are sensor issues or the cylinder with misfire issues. But if it's not saying anything specific then you can go down the list.
- All sensors are functioning properly (there are lots of them)
-All connections are good and grounds are good (including ignition switch and starter circuit wiring)
-Plugs and plug wires are all good
-Coil is good (single cam Subies usually have 1 coil, dual cam may have coil on plug)
-Wiring harnesses for coil(s), injectors ,sensors, and ECU are good
-ECU is good (if it's bad replace the alternator as well. Voltage spikes kill many an ECU)
-Voltage supply to ECU is consistent and correct (See above, you might find it before it fries your ECU)
-Drive by wire accelerator pedal should be checked for proper signal/function if you're running the Subaru ECU, and make sure that it's wiring is secure and complete.
-Valve adjustments are correct (Single cam Subies have manual valve lash adjusters, they just don't typically need much attention. Dual cams usually have hydraulic lifters.)
-Fuel supply is good (pressure, consistency of flow, filter clean, etc.) and good over time (an overheated fuel pump failing can be a thing)
-High idle or idle bypass solenoid working as intended if so equipped.
-Fuel injectors are functioning properly (You can't fix a wonky fuel injector with anything that comes in a can. If they are gummed up, or intermittently working, pull them and send them out to be rebuilt.)
Welcome to the world of EFI. It's much easier to live with most of the time. But when something goes wrong it's no different that carbs and ignition points. Go through your check list one logical step at a time until you find the b***ard that's causing all your pain.