Gravitational potential energy is a function of solely vertical motion of an object, so in a case where a body has both vertical and horizontal component in its velocity vector (at an angle), we only deal with the vertical component when calculating the kinetic energy that is being transformed to potential energy at the peak height. Thus the angle doesn't matter.
In your first case, you broke the law of conservation of energyvertical velocity at maximum height is zero, so making $KE_f= \frac 12 m(vcos\theta)^2$ and not zero when dealing with vertical partition of the motion is where your problem is emanating from. Based on the law of conservation of energy, the vertical kinetic energy computed with the vertical component of the obiect's velocity vector from the start of the motion is transformed into potential energy at the peak height of the flight/trajectory (the velocity remaining in the body is the horizontal component), so at the apogee the object stopstops moving vertically and vertical velocity is zero so kinetic energy for the vertical component is zero. In the inclined, the conservation of energy law is agreed with so it's correct.
In a two dimensional motion like the first ramp case, the horizontal velocity component is independent of the vertical velocity component,body stops moving both horizontally and calculating potential energy at height depends only on the vertical velocity component which has to be zerovertically at the apogee, hence the vertical kinetic energy of the body is zero. In the ramp case, aspeak height (as long as it doesn't fall off the top of the ramp and follow a parabolic trajectory down, the kinetic energy at the apogee in this case is zero (both vertical and horizontal)), but we still use the vertical component of the velocity to calculate the kinetic energy being transformed to potential regardless.