While there is, unfortunately, no way to completely protect yourself from violence in an urban area, having a plan is helpful. You might want to plan each day around one or two activities, such as an art museum. This way, you can look up where you are going and be aware of the area's geography and risks. You are also less likely to become lost or disoriented.
I once planned a day in Munich around the Deutschesmuseum--a huge science museum. I ate near the museum and lots of my wandering around was in the same general area. My focus on one activity also made it look like I had a sense of purpose and didn't stand out. That said, I do realize this imperfect solution won't work for everyone in every given place. I was a white woman from the US in Europe, which gave me a certain level of privilege others wouldn't be given. Even in 2021, the idea of 'blending in' in countries where racism exists is still largely based on ethnicity and skin colour.
When travelling far from home, it's important to let someone you trust know where you are, how long you will be there and when you're coming back. This is absolutely essential when you are going to a remote location doing a high-risk activity, such as caving or climbing. Many hiking trails even require signing in and out at a visitor centre. If you are simply going to a highly-populated area like a town or city, it's less important but still a smart idea.
It is also important to be ready for different kinds of weather. I always bring multiple layers, including shirts, sweaters, at least one thick warm layer and a rain jacket. Again, even if you aren't outside for a long time, you don't want to be wet and cold on an otherwise enjoyable day.
Lastly, it's a good idea to look up emergency numbers for your location in case you are in a bad situation of any type.