Why did Adolf Hitler attack USSR?

Quite a controversial matter as it is, History was written by the winners how they wanted it to be written. What we all learn in our history books is that Hitler striked the USSR as it was seemingly and easy target and quite unprepared for any serious resistance whatsoever. Now there, actually what might have been the reason behind this is that Stalin was gathering forces in an attack formation to roll through Europe, which would be weakened greatly by the war with Germany. That is why all the factories were gathered at the front lines and a defence line was not even built due to Stalins attack plan, there would be no need for defence,and if not for Hitler relising this and attackin before Stalin could set his plan to action, the USSR might have easily established total control over Europe,and then nobody,not even the USA would be able to do anything about it.