networkn: I still think this was likely a potential hijacking or interference with the crew. They really need to lock the cockpit when the plane reaches an altitude of 1000M, which prevents people getting access to the cockpit, removes any choice the pilot has to be co-ocerced into opening the cockpit, and pretty much does away with any hijacking (Since access to the cockpit is the only reason to hijack a plane).
It's locked now from take off actually before take off. There's the possibility that the crew could be incapacitated and there is no way of anyone getting into the cockpit to resolve the situation, the aircraft just flies until it runs out of fuel, this could even be the case in the MH370 incident.
In case you are suggesting the cockpit door be locked automatically and not be under control of the pilots, the crew have to have control of the cockpit lock. There are times when they will need to leave the flight deck during flight.