The difference is that in tests you can mock out the $window object so that instead of using the real alert it stubs to console.log or something else. If your code called alert directly then there is no way to override the real alert so in your tests you would see alerts popping up whenever your method used an alert.
Beyond just testing, in theory you could even use an alternative provider for $window which had an extra fancy alert implementation. Imagine if you wanted to use an alert built on bootstrap dialogs. Using the $window provider would permit you to change this in one place by injecting a new implementation and none of your other code would change.
You will not see a difference in your running code (both perform identically) but loosely coupling your code like this pays off later.