Static and dynamic solar coronal loops with cross-sectional area variations