Hi Aimee, all of the Baltic states are very safe for walking around, still apply the usual city 'precautions' & you'll be fine.
As for tours vs DIY, here are our thoughts.
If you actually moor up in Stockholm, you can follow the waterfront for a couple of miles straight into the city centre. From here, you have easy access to the shops, the Palace, museums & gardens. Our best tourist spot there was the Vasa Museum which is on the other side of the bay to where you moor up, but easily walkable on the flatish paths. However, recently the ships have moored up a long way from Stockholm & charged for 'tours' to & from the city taking about an hour each way. You can use the train, but it's not that frequent. Check your port location before planning your day here.
At Helsinki, the ships usually moor up by the ice rink, you can easily walk into the town from here (as well as Sebilius Park), check the route on Google earth or such. Basically leave the port area & turn RIGHT - the buses turn left & go through downtown, but by turning right you can follow the water, then cut through a park & end up at the lively market at the bottom of the main road/park area.
Tallinn usually lay on a shuttle bus & the ancient town itself is well worth exploring if you are okay with hills & cobbled streets. There are plenty of old parts of the town to get away from the world.
Sorry, not been to Gdansk.
Oslo usually have you mooed up by the castle walls, you can walk through them if you like - it still has guards & ceremonies taking place. To get to the town & Palace, follow the waterfront beyond the old walls & turn right across the large square. When you get to the main road, the city is to the right, the Palace to the left. Alternatively if you take a tram to the other side of the Fjord from where the ship is docked, you'll fnid the Viking & Kon Tiki museums.
Hope these give you some thoughts,
Last: Cunard Queen Victoria January 2016
Next: Oceania Nautica Aug 2016
Then: P&O Oceana December 2016
Golden, Grand(2), Caribbean, Royal, Sea(4+1 aborted)
Adonia(4+2), Arcadia, Artemis(2), Aurora(5), Azura(2), Britannia, Oceana(3), Oriana(12), Ventura(2), Victoria(5)
QM2(2), QE2(9), QV(7), QE, Caronia(2), Minerva, Minerva II, Fred.Olsen(8), NCL Jade, =X= Eclipse, HAL Ryndam, Aza.Journey