It looks like I have made an error in my query and edited it.
It works good now with the following queries:
user.assignedPlans -all (assignedPlan.servicePlanId -ne "efb87545-963c-4e0d-99df-69c6916d9eb0") ---- This checks if a user is on Exchange Online Plan 2, if not it will be added to the group.
You can also use this to filter out E1 licenses:
user.assignedPlans -all (assignedPlan.servicePlanId -ne "9aaf7827-d63c-4b61-89c3-182f06f82e5c")
It doesn't look to be possible to separate E3 and E5 at this moment, unless you find a serviceID for a service that doesn't come with both subscriptions. So all in all it is a semi workaround for filtering on licenses.
When it comes to the problem I had concerning users being removed it sorted it out with the new query. It looked to be the query that checked if it was enabled or disabled that made them be removed and impossible to be added (this I have no idea how happened).
Thanks.