Germany wanted to continue participating in the NATO nuclear sharing agreement so that made the F-35A the only practical option. They considered purchasing the Eurofighter Typhoon instead but found that modifying it for the nuclear strike mission and then going through the certification process would be too expensive. When you have to rely on another country for your nuclear deterrent that cuts off your options.
The Gripen is fine for what it is. But it's very small with limited thrust so performance goes to crap when you load it up with a bunch of external stores for a long range strike mission.