Why didn't Paul and Silas declare their citizenship before they were punished?
At the beginning of Acts 16 the Holy Spirit gives Paul specific directions two times as to where not to go preach the gospel and then gives him a vision as to where he was to go to preach the gospel.
They were kept from entering Asia.
The spirit would not let them enter Bithynia.
During the night Paul had a vision of a man of Macedonia standing and begging him, “Come over to Macedonia and help us.”
After Paul had seen the vision, we got ready at once to leave for Macedonia, concluding that God had called us to preach the gospel to them.
It seems like it was God's plan for them to be arrested and suffer and here is Paul and Silas singing hymns to God in the mist of all that. The earthquake was a huge sign from God that he was able to rescue them out of the prison.
They chose to remain and the jailer witnessed all this And was brought to his knees.
I think this is the vision of the man Paul saw praying to God To come to Macedonia And preach the gospel to them. It was for the jailer and his family and others in that area.
About midnight Paul and Silas were praying and singing hymns to God, and the other prisoners were listening to them. 26Suddenly there was such a violent earthquake that the foundations of the prison were shaken. At once all the prison doors flew open, and everyone’s chains came loose. 27The jailer woke up, and when he saw the prison doors open, he drew his sword and was about to kill himself because he thought the prisoners had escaped. 28But Paul shouted, “Don’t harm yourself! We are all here!”
29The jailer called for lights, rushed in and fell trembling before Paul and Silas. 30He then brought them out and asked, “Sirs, what must I do to be saved?”
Later on and Acts 22: 25-29
We see where he does declare his Roman citizenship.
25And as he was stretching him with the thongs, Paul said unto the centurion who was standing by, ‘A man, a Roman, uncondemned — is it lawful to you to scourge;....
So this time he did use his Roman citizenship because the Lord had plans for him to testify in Rome.
on the following night, the Lord having stood by him, said, ‘Take courage, Paul, for as thou didst fully testify the things concerning me at Jerusalem, so it behoveth thee also at Rome to testify.
Again your question was:
"Why didn't Paul and Silas declare their citizenship before they were punished?"
So after looking at context of the two different scenarios one can conclude that the Lord was leading him differently every step of the way to go and preach the gospel and witness to where the Lord wanted him to go.