In most cases, the ATM provider will know that there was an error, and the money will automatically be returned to your balance within a few minutes.
If that doesn’t happen, you have 2 options:
Contact the ATM provider first
Every ATM has a contact number. Call them and tell them what happened; they should be able to fix things. Before you call, have the transaction date and time, and the ATM code and operation number, handy.
If the transaction is pending
If the transaction is marked as pending in your activity, the money should automatically return to your account in 7 days.
If the transaction is completed
If the transaction is marked as completed in your activity, submit a dispute.