RaycastHit2D hit = Physics2D.BoxCast(new Vector2(transform.position.x - 0.35f, transform.position.y - 0.25f), new Vector3(0.1f, 0.2f, 0.1f), 0, Vector2.left, wallLayerMask);
The Box-RayCast should only hit layers that correspond to the wallLayerMask (Ground). However, it still hits the player (default) and cannot find the error.
It’s because you are passing the layer mask in the distance place (you can check the API for BoxCast). In order to fix your problem, you should do this:
RaycastHit2D hit = Physics2D.BoxCast(new Vector2(transform.position.x - 0.35f, transform.position.y - 0.25f), new Vector3(0.1f, 0.2f, 0.1f), 0, Vector2.left, distance, wallLayerMask);
Replace distance with your desired value in the code above.