I'd also argue that however the movie did after the fact, turning down roles you don't understand is probably the smarter option. Maybe those other movies would have also flopped if they had Connery in those roles.
Like I can't picture him doing a good Gandalf. It wouldn't be Gandalf, it would be Sean Connery in a wizard outfit. I can't think of any roles where Connery played someone who wasn't Sean Connery. He brought a lot of charisma to his roles but not a ton of range.