It completely depends on the accident and airport.
For example if I crash land on 10R at San Francisco, and it's a fairly quiet time of day (eg below the capacity of one runway), the airport could just use 10L and continue operations as normal. Similarly if there was no wind they could just switch to 1/19 L/R instead of 10/28 L/R. I'll discuss this toward the end of this answer.
Even if the crash didn't damage the runway, if the accident didn't damage the runway and the aircraft could be safely moved the airport would be back to normal as soon as the aircraft was moved and the runway had been checked. This could be within an hour.
On the other hand if at a single runway airport, with severe damage to the runway and a need to leave the aircraft in situ to be inspected, it could take several weeks.
In the cases you mentioned, BA 38 landed short of the runway. The airport was closed to arrivals for a few hours, however, and hundreds of flights were delayed, cancelled, or diverted. In the meantime, the runway in question (27L) was closed entirely for arrivals until 3 days later when the aircraft was recovered. However the runway re-opened on the day of the accident for departures only. As Heathrow typically operates with one runway for Departures and one for Arrivals, this had minimal impact on operations: ref
In Turkish flight 1878, the aircraft impacted Runway 5, then again on Runway 35L, but as far as I'm aware no significant damage was done. The other runways were inspected and used until the aircraft was moved. Ataturk is a busy airport, but not so busy that it can't cope with the loss of a single runway. Again a few hundred flights were delayed, cancelled, or diverted.
In neither incident was wreckage left on the actual runway, so once inspected they could be used as normal. There was some disruption in both cases - although no more than that caused by bad weather. If the aircraft had remained on the runway in either case, however, and had the accidents been at a single airport runway (eg London Stansted rather than Heathrow), the airport would likely have been closed for several days.
Another interesting case is Asiana Airlines flight 214 - an accident at San Francisco which closed the Airport for a few hours, and the runway for around a day. The other two runways (1/19 L/R which are perpendicular, as San Francisco has 4 runways arranged as 2 pairs) re-opened after around an hour and meant there was minimal impact, along with the parallel runway (10L/28R) which re-opened 24 hours later. The accident runway (10R/27L) re-opened around a week later.
One thing to note is that in most cases, an airport only needs runways in one direction - so for example at San Francisco there is a lot of resilience in the runways. As long as the accident doesn't cause damage too close to the "crossover" of the runways, San Francisco should almost always be able to operate at near full capacity shortly after an accident, even with a runway closed, due to always having a pair of runways available. Airports such as Heathrow with a single pair of runways are less resilient