We should be clear on one thing regarding money: Iran didn't fund this with any part of the $6B, and no part of the $6B opened up other funds to use for this. A terrorist operation like this doesn't just come together over a few weekends. This has been planned for a long time. It was going to happen whether or not there was a prisoner exchange, and whatever money Iran put toward it (if any) happened without figuring in a future deposit from the United States to cover any checks they might write.
That doesn't mean we should be giving Iran money. It was a transaction, a trade. We bought freedom for some people. It was a transaction I supported on the theory that it's always better to bring Americans home when you can. But that doesn't mean I was right. Regardless of the technicalities or the good motivations, we still agreed to give Iran money, and that should make us wary in the same way (but on a much bigger scale) as a liberal or conservative might be wary about giving money to Hobby Lobby or Target. Whether or not your money has anything to do with something you disagree with, you're still giving money to an organization that doesn't align with your values.
But, again, that transaction had nothing to do with Hamas attacking Israel, beyond the basic fact that some of the bad actors involved might overlap here and there.