When I make a stroke using the pen tool in Corel Painter 2018, a new layer is automatically generated. I found no apparent way to fix it. Is there a way to avoid it?
I don't use Corel Painter, however as in other similar applications, the "Pen Tool" is used for making vectors, which are different from normal strokes you would make with the Brush tool.
The Corel Painter documentation on the Pen tool is here
What this means is that each vector path you make with the Pen tool is a separate object with a stroke and fill. Each of these generates its own layer, so that the object is still editable. This is normal and how the tool is supposed to work. It works similarly in other applications which also have a Pen tool.
If you don't want that to happen, then perhaps ultimately, the Pen tool is not what you really need. Perhaps you would be better using the Brush tool to paint with.
Also note that when you export your art as a jpeg or png, when you have finished creating your work, all the vecotor layers in your Corel document will be flattened and rasterized anyway.