How do convolutional neural networks (CNNs) work, and why are they effective for computer vision tasks?