In some aircraft which have large wing deflection due to bending, do ailerons or flaps not get stuck or bent themselves? In the case where hinging axis is also bent how do ailerons operate?
Flaps and ailerons are weak in bending and have multiple hinges along the span. Also, as you can see in the photo, the flaps are segmented which not only helps to optimize the deflection angle over span but also limits any sideways offset of the hinge points due to bending. Using only glassfiber or aramid fiber for the flaps makes them very flexible so they easily follow the bending of the wing.
Flexible flaps are also torsionally flexible. This necessitates to distribute the mass balance along the span which is normally achieved by glueing a brass rod to the forward edge of the flap which reaches into the flap cutout of the wing.
The control surfaces are connected with pushrods. Those are segmented as well and have ball joint swivel bearings between them to allow for some misalignment. The joint is held in place by a swiveling buckling support; in the sketch below (own work) it is attached with its hinge point at the lower wing skin; it could as well be placed horizontally in the wing and be supported at the spar web.
If you follow the deformation of the wing, you will see that in this example the pushrods sit near the upper surface of the wing. This will make them relatively longer when the wing structure deforms in upward bending, and will create a negative aileron deflection (trailing edge up), which reduces lift on the outer wing and reduces bending. The linkage can, therefore, be used to limit loads and dampen the bending motion.
The design has to account for the maximum possible elastic deformation and for differences in thermal expansion between structure and linkage.