What "closed automatically" means
It means the platform or broker closed your position without you clicking close. The trade tab will show it as closed, usually with a comment that hints at the reason. The trick is reading that comment.
The common reasons
Your stop-loss or take-profit was hit — the most frequent cause. A margin stop-out, where the broker force-closed trades because your margin level fell too low. A trailing stop catching up to price. An expiry on certain CFDs or futures-based instruments. Or an EA closing the trade by its own logic.
How to find out which
Open the closed trade in the account history and read the comment field: 'sl', 'tp', 'so' (stop-out), or an EA note tell you a lot. Check the price and time of the close against your stop, target, and margin level at that moment.
How to prevent unwanted auto-closes
Know where your stop and target sit before you walk away. Keep enough free margin that a normal move will not trigger a stop-out. Understand any expiry on the instrument. If an EA manages trades, know its rules so its closes do not surprise you.
Broker's fault or yours?
Nearly always a rule you set or a margin situation you created — not a fault. The rare exception is an unexplained close with no matching stop, target, margin event, or expiry, which you should query with support and document.