Since the addresses are hashes of a public portion of a public/private ECDSA keypair, what would happen to two different people with different keys that hashes into the same address? How would transactions to those addresses be handled?
In elliptic curve cryptography, public keys are derived from private keys, with seemingly random distribution. You are correct that two different private keys could produce two different public keys that just so happen to hash to the same Bitcoin address.
A SCRIPT_SIG of the transaction that spends from that address would need to provide:
- A public key that hashes to that address
- A signature of the transaction produced from a private key that matches the given public key
Since two different key pairs could both meet this criteria, either one of them could spend the bitcoins.
However, this is very unlikely. So much so, that it's not even worth considering as a possibility. The best metaphor I've seen on why this isn't an issue is explained in this video: https://www.youtube.com/watch?v=ZloHVKk7DHk
As @Meni answered, both people would have access to the funds.
To illustrate how unlikely this is to ever happen, consider the following simple attack:
while True: genereate new keys and address if address has funds: transfer to ME
This attack can scan through an astronomical number of addresses each day. And it is so simple, anyone can carry it out and get rich! Except that it doesn't work. If it did, the bitcoin network would quickly collapse.
The reason it doesn't work is that the address space is so big, it is extremely unlikely for a collision to ever happen purely by chance (bugs in random generators are a different story...).