If you sell options, just remind yourself occasionally that you can be assigned. Lots of new options traders never think about assignment as a possibility until it actually happens to them. It can be jarring if you haven't factored in assignment, especially if you're running a multi-leg strategy like long or short spreads.
For example, what if you're running a long call spread and the higher-strike short option is assigned? Beginning traders might panic and exercise the lower-strike long option in order to deliver the stock. But that's probably not the best decision. It's usually better to sell the long option on the open market, capture the remaining time premium along with the option's inherent value, and use the proceeds toward purchasing the stock. Then you can deliver the stock to the option holder at the higher strike price.
Early assignment is one of those truly emotional, often irrational market events. There's often no rhyme or reason to when it happens. It sometimes just happens, even when the marketplace is signaling that it's a less-than-brilliant maneuver. It usually only makes sense to exercise your call early if a dividend is pending. But it's trickier than that, because human beings don't always behave rationally.
How can you trade more informed?
The best defense against early assignment is simply to factor it into your thinking early. Otherwise it can cause you to make defensive, in-the-moment decisions that are less than logical.
Sometimes it helps to consider market psychology. For example, which is more sensible to exercise early: a put or a call? Exercising a put or a right to sell stock, means the trader will sell the stock and get cash. The question is always, Do you want your cash now or at expiration? Sometimes, people will want cash now versus cash later. That means puts are usually more susceptible to early exercise than calls, unless the stock is paying a dividend.
Exercising a call means the trader has to be willing to spend cash now to buy the stock, versus later in the game. Usually it's human nature to wait and spend that cash later. However, if a stock is rising less skilled traders might pull the trigger early, failing to realize they're leaving some time premium on the table. That's why early assignment can be unpredictable.