If you do something from scratch, you do it without making use of anything that has been done before.
What does it mean to do something in scratch?
To create something from scratch is to make it without any ingredients or materials prepared ahead of time. The scratch in from scratch originally referred to the starting line of a race "scratched" into the ground, from which all runners would be starting without a head start.
Why do we say from scratch?
For the term made from scratch, this blog writes: This use of scratch derives from a line or mark drawn or scratched into the ground to indicate a boundary or starting-point in sports, especially cricket and boxing. That meaning of scratch goes back to the late 18th century.