Under EU laws, you're free to move any form of food from one EU country to another. (OK, for the pedantic, there are occasionally temporary restrictions relating to such things as BSE, but they certainly don't apply to jars of food for toddlers).
So, you'll have no problems with the Spanish customs staff. (I doubt that you'll even see any).
With the exception of certain dangerous items, you can put what you want into the hold of an aircraft. So you'd have no problems at all if you packed your son's food into your hold baggage.
I can't see why you'd need to put very much food into your hand luggage. The general safety rules (i.e. the ones which have been in place for many years, well before the current 'heightened security') don't prohibit either food jars or powdered milk from carriage within the cabin. However, the (relatively) new security rules prohibit you from taking liquids and gels (which would include the type of toddler food that comes in jars) through the security checks unless they meet certain criteria. There's an exception which might be relevant to you (quote): "Liquid baby food or sterilised water, sufficient for the journey, can be taken through airport security. The accompanying adult will be required to verify by tasting."
For the full rules, see here:
http://www.dft.gov.uk/transportforyou/airtrave l/airportsecurity/requirements
If you put most of your son's food into the hold, and comply with the rules on 'liquids' for anything you take through the security checks, you'll have no problems.
Chris