You don't need to be a full Captain to command a ship. Picard could've been a Lt who was eventually promoted to Lt Cmdr and given command of the Stargazer for years (which led to other promotions until he was a full Captain). Since he was in command of the Stargazer during the Battle of Maxia I'm guessing the battle that killed the original Captain was years earlier. Seeing what we learned later, it might've even been a battle with the Cardassians that caused it.