I have a visa type D (multiple) for Italy. My flight has a stop in Barcelona. Would it cause any problem for me that my first time entry to Schengen is not to Italy? My stop there is for 4 hours and I am not going to leave the airport.
No, that is not a problem. A type D visa allows you (among several other things) to transit through other Schengen member states on your way to or from the issuing state.
Schengen Borders Code, article 6 paragraph 5:
By way of derogation from paragraph 1:
(a) third-country nationals who do not fulfil all the conditions laid down in paragraph 1 but who hold a residence permit or a long-stay visa shall be authorised to enter the territory of the other Member States for transit purposes so that they may reach the territory of the Member State which issued the residence permit or the long-stay visa, unless their names are on the national list of alerts of the Member State whose external borders they are seeking to cross and the alert is accompanied by instructions to refuse entry or transit; [...]