Those uses were incidental. Both cities were inhabited by many pesky creatures called (non-military) people.
Nearly every US military base has civilians living in and around it. Does that mean they're not legitimate military targets?
Take the City of Baltimore, for example. Naval shipyards at the harbor, an Army Testing Range right next door, a National Guard depot facility just north of town, an Air National Guard base just northeast of town, NSA headquarters just south of town.
It's not a military target? You gotta be kidding yourself. I can guarantee that it had (probably still has) a number of nukes targetted at it by the Soviets / Russians.
Few and far between are military bases that are isolated from civilians and have no civilians living at them. Area 51 and the Crystal Palace are the only ones I can think of off the top of my head.