Andy locks himself there to play music. Why would he do that? I get the philosophical aspect but it is a great risk. He is gaining favour with the prisoners but he could get moved to another cell or worse. All the work he has done tunneling out could go away.
And that philosophical aspect rules the situation.
Why would he do that?
The people, locked up into that prison knows that they won't be getting out anytime soon. Andy knows the people have lost hope. They are getting habituated to the prison. Like Brooks.
Brooks's death shook Andy. He could clearly picture that the prisoners who have spent/are going to spend a long time in there, may end up in the same way.
He had sent the letters to the higher authorities for 6 long years and just received the grant. He had seen that hope is the way to get going in the long run. He wanted to share his feelings with everyone.
There was no way he could go and talk to others about hope. And what would he have said? Besides there's no guarantee that people would have understood. Also anybody could have easily informed the warden about this. Playing the music was the easiest way to do that with lesser risks taken.
He Played music to instill hope and a sense of freedom into the minds of the prisoners. He could have listened to the music alone. He took the risk for a greater good. You cannot bound music in a room when you are in the right position. You can make the warden powerless in the right situation. Everybody knew that the warden would not allow to play music in the PA system, still he managed to play it for few minutes. The music can send the message(of hope) in a way like no other can.
....but he could get moved to another cell or worse. All the work he has done tunneling out could go away...
I think you meant another prison. They would not move him to other cell. He did not do anything like organising and breaking the rules with the prisoners in the nearby cells. He was really composed, didn't have much friend, talked to few people. So, he knew that they wouldn't move him to another cell.
Now, they could have moved him to other prison. And chances of that is too less too. First, he has proved his worth to the warden. He has proved that he is good in accounting and he has managed their tax files for a while efficiently. So, losing him would be their loss.
Also, Warden Norton was involved in illegal monetary business. Now that Andy knows everything about them, he has the upper hand. There was a risk involved with sending him to another prison.
Lastly, it would not be a good impression for the warden to send Andy to another prison, on the grounds of a prisoner being uncontrollable.
And as a composed person Andy probably knew all of this, so he took the risk.