Optimization-Based Verification and Stability Characterization of Piecewise Affine and Hybrid Systems