Yes. In general, EU citizens who wish to work in Spain must have a Foreigner's Identity Number (NIE) issued by the Ministry of the Interior, which will be their Spanish Tax Code (NIF), or, failing that, the Tax Code "M" issued by the Tax Administration.
Citizens of the European Union and of member countries of the European Economic Area (Iceland, Liechtenstein and Norway, in addition to Swiss citizens) there apply the same identification rules as to foreigners, but they will obtain a NIE that will be stated on their “community regime card" when they register in the Central Register of Foreigners, which they are obliged to do if they reside in Spain for more than three months, in accordance with the provisions of Royal Decree 240/2007 of 16 February on entry, free circulation and residence in Spain of citizens of European Union Member States and other Party States to the Agreement on the European Economic Area.
When they register in the Register, the Police simultaneously assign them a Foreigner's Identity Number (NIE) unless they already had it. If they do not reside in Spain for more than three months, they are not obliged to register and do not have an identity card. However, they can obtain the NIE, and in fact must request it, if they have personal, social or economic relationships with Spain, even if they are not resident. However, as with other foreigners who do not have a NIE, the Tax Agency may assign a Tax Code (NIF) with an initial letter "M” to individuals who do not have Spanish nationality (whether or not resident in Spain), either temporarily, due to being obliged to have an NIE, or definitively, due to not being obliged to have it (in this latter case, due to being excluded from the scope of application of the regulations on foreign individuals, diplomats, international civil servants, among others).