Ok, nearly all cars fire before TDC, not at it.
That's what the degrees timing is, how many degrees before or after TDC that the plugs fire.
You want to fire late enough that the piston can reach TDC without having to push to hard against the expanding fuel, but early enough that the fuel is already expanding at TDC to get the most out of it.
And when the ignition is advanced or retarded it means the timing was moved up or down.
Knocking sounds like a badly tuned diesel, because that's what it is.
The fuel is being ignited by the compression instead of the spark.
Pinging is much more tame, the fuel is still being ignited by the spark, but because of whatever is off the fuel is igniting just a hair faster than expected, it sounds about like a bunch of BBs rattling around in the engine.
Temporary pining under heavy uphill climbs or accelerations are considdered normal for a lot of engines.
The damage and sound come from the same thing.
When the fuel ignites too early the piston encounters way too much force as its still traveling towards TDC and it creates a shock which jars the piston, valves, crankshaft, everything, just as if you had hit it with a hammer.
It can cause bent parts, cracked parts, and because the burning fuel is being compressed more the temperatures skyrockets and can lead the melted/warped parts.