How does a project manager assess the risk of things going wrong and take that into consideration when planning the time needed to complete a project?

1. how does a project manager assess the risk of things going wrong and take that into consideration when panning the time needed to complete the project?