This problem has occurred on my ipad 2 once when I noticed that its screen orientation did not changed when I rotated ipad from portrait to landscape mode or vide versa, I tried 4-5 times and more over this problem is not limited to ipad 2 but it happens on ipad 2 as well that iPad Screen Does Not Rotate When iPad Orientation Changes.
After Searching for the solution to this problem I found out this could happen in cases when you have set slide switch on ipad 2 to lock the rotation. Go to Settings > General > Use Side Switch To setting as shown in the image below.
Slide switch on ipad 2 is mentioned in the image below.
or you may have locked the screen to remain in one position in ipad taskbar when you slide the running apps to right side you see it as shown in the image below. Double-click the Home button and swipe from left to right and check if Rotation lock this step is same for both ipad and iphone as shown in the image below
In my case I checked both of these settings, but it does not solve after altering orientation settings in these sections as the issue was not because of any of these two settings in ipad or ipad 2. If here is no lock symbol, in the multitasking taskbar then we would suggest you to turn off your ipad or ipad 2 as restarting it should solve the problem as this rotation issue did not came back when we restarted our ipad when faced this problem.
For those who have tried restarting, we would recommend you to reset your ipad by pressing down the home button and power / sleep key at the same time until you see the apple logo. One more thing to note here Not all iOS apps are designed to rotate. Some may use only portrait or landscape mode, or switch depending on the content. To test screen rotation, open the Calculator app that comes with your device. If the screen does not rotate as expected while using the calculator app, continue troubleshooting.
If still after doing all the steps above it does not solve the problem for you, follow this troubleshooting guide by apple support to solve this issue. The last working method to solve this could be restoring your iphone or ipad, read the step by step procedure here