Why does my nexus 6p goes black after call is answered when I make or recieve a call as soon as I click the call or answer button the screen goes black. And I can't hear anything thru the ear speaker. However, when I put it on speaker it stays normal. What can cause this issue?

Thank you for your help guys
Your phone has an hardware issue. The proximity sensor is broken or is covered.

But before, did you put a screen protector, such as tempered glass, may it doesn't have  proper cutouts.

As a workaround, I'd suggest you set up the power button to end calls (Settings -> Accessibility -> Power button ends call).

You should consider taking the phone to a repair center if the above don't work.