In JFK, you will indeed get access to an American (or American / BA) lounge in T8 - if you have status with American or another OW alliance member you may have more options
https://www.aa.com/i18n/travel-info/...um-lounges.jsp
In Madrid you will be able to use the Dalí lounge in T4 (since your flight to Lisbon departs from there)
https://www.iberia.com/es/salas-vip-iberia-madrid/dali/