It is possible to reverence multiple custom object in Velocity. You'll want to be careful with how Marketo handles the record limits. It will only return the first 10 records unless you've already changed your limit: https://experienceleague.adobe.com/docs/marketo/using/product-docs/administration/email-setup/change-custom-object-retrieval-limits-in-velocity-scripting.html?lang=en
One of the major issues I am seeing with your code is that you're trying to reference an array/list like a single record with no array index reference. You'll probably need to loop through the array and use the current loop object as your reference. You're naming each object $emailAddress but that doesn't actually pull the email address necessarily unless your list is just a bunch of email addresses.
This code is likely imperfect but you could do something like:
#foreach ($itemA in $objectA)
#if ($itemA.id.equals($lead.itemID) && $itemA.elementA.equals("foo") )
#set ($returnStringA = $itemA.elementB)
#set ($returnStringA = "default")
#foreach ($itemB in $objectB)
#if ($itemB.id.equals($returnStringA) )
#set ($returnStringB = $itemB.elementA)
It may help to break the problem down to smaller parts and get each one working before putting it all together. Then you can work on code optimizations if they're available.
... View more