Since 2020, all aircraft in most controlled airspace are required to have Automatic Dependent Surveillance-Broadcast (ADS-B) out. This means they are required to send, among other information, their GPS coordinates and altitude at least once per second. (See 14 CFR 91.225)
Using these GPS coordinates, which contain time and position data, ground speed can be calculated.
The data GPS data is collected mainly from community "feeders" who build ADS-B recievers and transmit the data to sites like flightaware, adsb-exchange, etc. If you're wondering why someone would do this for free - well some people think it's fun, and some sites offer premium memberships in exchange for feeding data.
GPS data of the accident aircraft seen here is from the ADS-B transmitter.
Regarding your other questions - the data is not even available to the crew on board. It is purely for ATC separation of aircraft in controlled airspace, as well as dinging people for illegal stunts or unauthorized entry into certain airspaces. If you have ADS-B "in" you can also use this to augment your situational awareness by knowing the location of nearby broadcasting aircraft.
Note 0: Heading is calculated simply using a straight or smoothed line between the GPS "hits". This is not entirely accurate since aircraft usually have at least some wind correction angle relative to their ground track. During aerobatic maneuvers and accidents the actual heading (that is, the direction the nose is pointing) of the aircraft is unkonwn and can only be guessed based on external knowledge of the aircraft attitude.
Note 1: ADS-B and most other surveillance methods cannot calculate "air" speed (that is, how fast the air is flowing over the aircraft). This is the speed shown on the airspeed indicator of an aircraft and is dependent on the relative wind. Consider a Cessna 172 flying at 100 knots indicated airspeed into a 50 knot headwind. The cockpit will register 100 knots, but the groundspeed is only 50 knots.
Note 2: GPS is transmitter via an ADS-B transmitter, which is a simply on-off device in the cockpit. It transmits the GPS coordinates to anyone with an ADS-B "in" receiver. This GPS data is used for tracking and surveillance but cannot be used for navigation (as far as I know).
Note 3: The rules governing who needs ADS-B are slightly more nuanced than I stated above, and I believe any aircraft which has ADS-B installed must turn it on during all operation. The "controlled airspace" restriction simply means aircraft without ADS-B are prohibited from many areas in the USA National Airspace System (NAS).