How can you discern which meaning of 怎么 as an interrogative should be used in a sentence?
Ermm, you posted " that my weather app predicted the today's weather terribly in Shanghai, "

Which I presume to mean: "Today's weather in Shanghai will be terrible."

That is the context: The weather.

There is no reason for your friend to then ask how you got to Shanghai, that lacks coherence. Her or his comment:

怎么又到上海了。 means: 'How come we are getting bad weather in Shanghai again!'

怎么How又again到to上海Shanghai了。