There can actually be multiple reasons.
People can be shy due to their life experiences. For example, a person who was once into rollercoasters, might have gotten into an accident in one. So that person would definitely be nervous to try it again.
There is also a fear factor involved.
When you are trying something new for the first time, your brain will immediately try to stay away from it. Its Kind of like an alarm in your head going DANGER DANGER! I DON'T KNOW WHAT THAT IS!
This is the same case with meeting new people. If a person meets a new person, most people won't talk much to them. But after talking to them and getting to know who they are, your brain feels less "scared" and you are not shy anymore.