If you’re in prison, this will be because either:
you’re there “on remand”, which means a judge has decided you have to stay in prison while you’re waiting for the next step in your court case, or
you’re serving a prison sentence after you’ve been convicted and sentenced.