Portugal would have been lucky with the 3rd place rule if it was implemented after the fact, which it wasn't. As it stood, it was clear beforehand that 3 ties would give a good chance to any team of being a best 3rd, because it means you didn't actually lose any game.
Different stages of the tourney have different rules and you don't have to excel at all of them to win it in the end. You play for your needs accordingly, starting from qualification, where you can even lose to Liechenstein at home and still win the following World Cup.
And if there's "luck" to be accounted for, everyone who have actually seen Portugal's games would say that Portugal was pretty "unlucky" with all of them, bar Croatia. Outstanding attacking stats and missed opportunities and freak goals conceded up the wazoo.