Can smaller trace width limit the current flowing through the PCB?
This might not be the only issue, but is almost certainly is one of them: the LM317 cannot supply 2A (its output transistor simply cannot pass that much current).

But even if it could, it probably would go into thermal shutdown. It is a linear regulator and linear regulators work by turning excess voltage to heat. That means the higher your input voltage is relative your output voltage, the more heat is produced for the same amount of current. You have your regulator set to 4V and are feeding it 12V. That is an excess of 8V At 2A, that is 16W worth of heat which is a lot. The thermal resistance of the larger packages in the datasheet indicate that it would be somewhere around 600C temperature rise. The LM317 goes into thermal shutdown long before you ever get anywhere near that. Probably somewhere around 125C which is only 300mA.

So if the current surge lasts too long and your capacitor is too small to provide enough reserve charge for the entire duration, the LM317 will try and help out, overheat, and protect itself by going into thermal shutdown.

When linear regulator datasheet says it can supply 2A, it means 2A under the best conditions, not all conditions.

And yes, thin traces cannot carry as much current because they have higher resistance so they heat up more and produce more voltage drop, which can either cause the trace to overheat or the voltage to droop too low.