It’s almost certainly from a loose connection, but I would replace the cap too, they are cheap
I would only clean and make sure the other connections were tight and I like to apply some silicone grease to prevent corrosion
, I would only replace the burnt wire.
You literally squeeze the female spade connector just a tad to tighten it, and resist excess wiggling when you push it back on, that can loosen one.
That cap appears to be a dual cap, three terminals, take it to a HVAC
supply place 99% sure they will have the right uf rated one, for $20 or so.
That burnt wire seems to be from the fan circuit I believe.