Boeing said Sunday that it discovered after airlines had been flying its 737 Max plane for several months that a safety alert in the cockpit was not working as intended, yet it didn’t disclose that fact to airlines or federal regulators until after one of the planes crashed.