How to install a junction box for a wire splice
It looks like the root problem is that the under-cabinet light was not installed flush to the back of the cabinet-wall corner.  The casing of the light itself is typically meant to be used as a junction box, and it should have enclosed the wires from the light, from the wall, the wire nuts, etc.
You should remove the light, feed the cable from the wall through the existing hole in the light fixture, reinstall the fixture absolutely flush the with cabinet bottom and wall, and then re-attach the wires inside the fixture. You may need to trim the wires a bit, or maybe you can just gently push the extra inches back into the wall (probably better).
If the hole in the fixture doesn't already have a clamp or you will need to add one (secures the cable &amp; protects it from metal edges). Personally I like the the plastic snap-in type (example) since they're easy and fairly flush. But there are others; your local store can advise you what they have.
The reason for insisting on there being no gaps is so that the wall cable is not exposed even a little; I believe if its done that way it will satisfy electrical code. References: just what I recall reading when I was installing similar lights myself.