Certainly people contain multitudes, but in Heinlein's case some of the diversity of viewpoint was intentional. The happy universalism of "Stranger in a Strange Land", the libertarianism of "The Moon is a Harsh Mistress', and the patriotic collectivism of "Starship Troopers" were, I think, the result of Heinlein choosing three very different political philosophies and exploring where they led. (This is not my original theory, but I can't seem to find a reference for it.)
To me it's one more sign of how masterful a storyteller Heinlein was that his embrace of the contradictions was conscious and not just a result of some sort of inner conflict.
Also, "The Moon is a Harsh Mistress" ends in a Socialist Revolution. (This is underscored in "The Cat Who Walks Through Walls" where the moon weary noir world-hopping protagonist comes from a worse version of the moon than "Harsh Mistress", one where the revolution was stamped out and is even more the dystopian "libertarian fantasy" people think "Harsh Mistress" is. The protagonist then later gets a chance to hop to "Mike's" version of the Moon and it is a far more pleasant, much more socialist place.) On the embrace of contradictions, it does seem to escape many how in "The Moon is a Harsh Mistress" the AI Libertarians hope to build on the Moon Libertarians dream to exist says "Libertarians can have a taste of Socialism, for a treat" as the main plot for the second half of the book.