The question you have posted is really a popular one, but you were not able to put it with clarity.
first things first js is synchronous by nature. The browser helps make it kind of asynchronous.
The call stack of js works synchronously but whenever it encounters asynchronous piece of code (setTimeout(),HTTP requests) it is sent to the browser's web api's.
where it is taken care of, like waiting for the response of the request or waiting for the timeout to complete. (The async piece of code is removed from the call stack for the time being, and call stack moves onto the next task)
After the web api recieves the response or the timeout fn ends it is then sent to the task queue which queues all the async code
It is where the event loop actually comes into play. It first check's whether the call stack is empty if it is then the first element of task queue is pushed onto the stack.
So in your case when you alerted ,it blocked the call stack and hence setInterval couldnt be pushed onto the call stack