- "The Naked Time": Scott can't figure out how to make the cold start work until Spock is able to supply the formula and work with him to make it happen.
Well, that one makes sense. The cold-restart formula was theoretical physics, never tested. As an engineer, Scott would deal with known and established practice. Spock's the theoretician, the one whose job it is to devise whole new possibilities. Scott's job is to find a way to make those theoretical possibilities happen in real life.
- "The Doomsday Machine": Down to the wire, Scott is taking too long to get the transporters working, until Spock, from the bridge, suggests he "try inverse phasing". Then it works.
But we have no indication that Scott couldn't have figured that out on his own. It could've just been Spock kibitzing.
- "The Ultimate Computer": Spock, not Scott, has the suggestion for how they might interrupt M5's control of the ship.
That could simply be a chain-of-command issue. Spock is the first officer; it's his job to propose solutions to the captain. Scott's job is to follow orders from the command crew. If Spock hadn't thought of it, Scott probably would've suggested it, but of course Spock wouldn't have overlooked the possibility, and naturally Scott deferred to his superior officer.
- "That Which Survives": Scott instinctively knows something is wrong with the ship, but only Spock is able to figure out what that something is and how to deal with it.
Technically it was the computer analysis that figured out the root of the problem. Since Scott's attention was urgently needed in the service crawlway, obviously he couldn't be the one to run the computer analysis. That's Spock's job as science officer.
- "Obsession": Standing next to Scott, it is Spock, not Scott, who makes the necessary adjustments to the transporter to get Kirk and Garrovick back.
The process of adjusting the beam was clearly shown to be a two-person job. Again, Scott was already busy doing his part, and Spock was adjusting the controls along with him.
And, as has been mentioned, probably the worst offender...
- TMP: Scott, who has been overseeing the refit of the ship from the ground up for eighteen months, cannot figure out how to get the warp drive working properly. Spock shows up and everything is just peachy within hours.
As with "The Naked Time," that could be a matter of theoretical physics versus practical engineering. Spock needed to devise a set of "fuel equations" in order to solve the problem.
Also, as you say, Scotty had spent 18 months rebuilding the engines. They wouldn't even exist without his efforts. All Spock did was finish calibrating them -- or rather, do so
faster than Scotty's team could've done by themselves. The only reason the drive malfunctioned is because Kirk forced the ship to launch prematurely, against Scotty's advice. It's totally unfair to Scott to say that he "[could not] figure out how to get the warp drive working properly." He just needed more time to calibrate it than Kirk was willing to give him. All Spock did was speed up the process.
And honorable mention:
- TWOK: Scott and all of his engineering staff and cadets are sitting around the engine room waiting to be blown to kingdom come. Not one person thinks to put on a radiation suit -- the biggest parts of which they are already wearing -- and go in and make the repairs. Spock has to end up sacrificing his life to do the repairs at the last minute.
Aren't you forgetting that Scotty was incapacitated and under McCoy's care when Spock arrived? Heck, the whole reason Spock left the bridge in the first place was that there was no response from engineering when Kirk called them. Presumably everyone there was too injured from the battle or weakened by radiation to take action. (Granted, Scotty was able to recover pretty readily a few moments later, but that could be due to McCoy's ministrations.)