The two balls roll down inclines from the same height and therefore must have the same velocity when they reach the end of the ramp. The change in height is the same, and therefore so is the gain in kinetic energy.

However, note that the time it takes to reach the bottom is not the same for the two balls. The curved path has a longer path length.

So why is the ball traveling the longer way there first?

Because it converts more of its potential energy sooner and thus has the higher velocity earlier. Since it moves faster earlier, it arrives at the bottom first.