As per your code, it looks like the ssh connection got closed after the few trails of giving the passwords to ssh session.
Whenever a new process spawned with spawn command, then expect will save the spawn_id for that expect process into expect_out(spawn_id).
spawn ssh -t root@$server_address "$*"
The debug which you have seen as below.
spawn ssh -t firstname.lastname@example.org sudo cat /etc/host
expect: does "email@example.com's password: " (spawn_id exp4) match glob pattern "s password:"? yes
expect: set expect_out(0,string) "s password:"
expect: set expect_out(spawn_id) "exp4"
As you can see in the debug information, the expect_out(spawn_id) holds the spawn_id from which it has to expect for values which is exp4 in your case.
As you can see, the connection got closed after few wrong trails thereby making the process exp4 no longer exits in the context. Since the spawn_id holds the reference to the same, expect will try to expect from that process and failed.
You can refer this question to know about how this spawn_id being used with standard input (which is reading input from console)