Lemon is made up of a mild acid called citric acid. So rubbing a mild acid on wounds and soft tissues will make it burning. This is due to the cells are partially damaged by mild acid.
Please remember that we can use the lemon to cure the pimple, foot horns etc. Here we are damaging the old cells with mild acid and removing them.