They began to filter the water around them for calcium.
This is also how they produce the shells , They would collect calcium from the water around and slowly "release loose glue" to push up to the front of the outer layer and it drys to be harder.
I really hope that this helps you out a lot.