Caravaggio was quite a rebel according to the sources with which I am familiar. He was in trouble many times during his lifetime.
He was commissioned by the cardinal to do a lot of his work, so the anwer above is correct. He probably did the religious paintings for the money. His painting were without a doubt, some of the best ever.
Too, you must remember that artists in any era will paint what they want to paint. This is the way it should be without a doubt. Take for example the Italian renaissance. Before the renaissance began, artist painted mostly biblical scenes. Then, after the renaissance artists began to paint potraits, landscapes and scenes for every day life. For the most part however, artist will generally paint their first love, regardless of what it is. However you must remember.....They did need finances to survive.