Does my education before master matter for phD?
It would be dishonest to omit your first place of study (and it would be a glaring omission on an application that would probably disqualify you).

In a PhD application you basically want to convince the admissions committee that you are capable of research or learning to do research. Therefore, if you show this potential in the process of obtaining a masters, the place you studied before your masters means a lot less.

That doesn't mean you can just ignore your first degree, but you are doing exactly what you should do if you want to get a PhD but have an unimpressive undergraduate record (due to grades, place of study, whatever): get into a masters program that will be more impressive and show your research potential. Try to get involved in publications and make connections with professors who can give you solid letters of recommendation.

Since you are changing fields slightly, you should also make sure that you take as a masters student all of the prerequisite coursework expected for applicants to the PhD program, particularly ones that might have been missed in an engineering-focused line of study. I can't give any suggestions for particular courses, but you should look at some representative programs you might be interested in for the future and make sure you have those courses covered.