It seems to me that since the empire was crushed the germanic region should be an easy pick after the Peace of Westphalia,instead they chose to go eastwards and clash with a rising power like Russia and ultimately they lost everything
If you are referring to the Great Northern War, then it should be noted that it was only one of numerous wars between Russia and Sweden. Russia and Sweden have been clashing for centuries over the year adjacent to the Gulf of Finland, with Russia attempting to gain access to the Baltic Sea. For the most part, the Swedes were able to keep the upper hand. On the eve of the GNW, Sweden was one of the powerful states in Europe, while Russia still not quite on par, with most of its army composed of poorly trained conscripts and lead my foreign mercenary officers. The Swedes routed a much larger Russian army at the battle of Narva so they had every reason to believe in a favorable outcome eventually. Otherwise they would have had to accept Russian territorial demands for the region of Ingria (the land around the city of Saint Petersburg.) Russia was able to come out on top and eventually defeat the Swedes at the battle of Poltava but this was not at all obvious without the benefit of hindsight.