It's not a law.
Materialism and atheism don't necessarily have anything to do
with each other; theistic materialism exists, and the materialism
part is still the same (it's incidental that there is or isn't a
god involved).
See "What is Materialism?" to better understand that part.