This is because according to an article in the Treaty of NATO, if there is an attack on any NATO country, then all other NATO member countries will provide military support to that country.
And therefore Russia does not want Ukraine to be a part of the European Union and NATO under any circumstances.