The ring-like structures that are observed in the cold dust emission by ALMA might be explained by pressure maxima in protoplanetary discs. To investigate the role of these pressure maxima in planet formation is of high importance. In this work, various episodes of planet formation are investigated in a transient pressure maximum that may develop between two regimes of different accretion rates. We study how such a pressure maximum collects dust aggregates and transforms them via streaming instability to large planetesimals and Moon-mass cores that can further grow to a few Earth-mass planets by pebble accretion, and eventually to massive solid cores of giant planets. We developed a complex numerical code incorporating the evolution of gaseous disc, growth, and transport of pebbles, N-body interactions of growing planetary cores with each other and the disc, including their backreaction to gas. Moreover, planetesimal formation by streaming instability and the growth of the planetary cores are also included in our model. A transient pressure maximum efficiently accumulates dust particles and transforms them into large planetesimals when the conditions of the streaming instability are fulfilled. From these planetesimals, Moon-mass core(s) can be formed and grow further by pebble accretion. As gas evolves to its instantaneous steady state, the pressure maximum vanishes, and the concentrated pebbles that are not yet transformed to planetesimals and accreted by the growing core, in some cases may drift rapidly inward. During this inward drift, if the conditions of the streaming instability are met, planetesimals are formed in a broad radial range of the disc. A transient pressure maximum is a favourable place for planetesimal and planet formation during its lifetime. After its disappearance, besides the formation of a planetary core, it can trigger planetesimal formation in a wide range of the protoplanetary disc.