I recommend checking out this great post by u/commiespaceinvader which discusses the historical debate between intentionalists and functionalists, two camps of Holocaust historians who disagreed on exactly this question! Since it tends pretty technical from a historiographic angle I recommend clicking the links in the answer for more background info.