In reply to Sv-hustler:
Please use code tags to make your code easier to read. I have added them for you.
The reason is that when you add the $display, the variable a now appears somewhere other than just the LHS of an assignment, so it becomes sensitive to changes on it.
BTW, It's strongly recommended that you use always_comb instead of always @(*), mainly because it's guaranteed to execute at least once at time 0.