Fun fact. When I flew Delta for the 4 years before the pandemic, anytime a pilot used the restroom, it was mandatory that a flight attendant take their place -- for exactly this reason. Sit in first class long enough you begin to get comfortable with common flight procedures.
Keep in mind it's not that the flight attendant can pilot a plane, it's that they can unlock the door to let the other pilot back in the cockpit.
While it is unlikely, it's still a possibility, and one that Delta, at least, is worried about happening.