Middlesex Savings Charitable Foundation, the nonprofit established by Natick-based Middlesex Savings Bank, is giving over $330,000 to 18 local nonprofits.