(All this is what I know of England, I don't know where you are or whether it is different in any of the other countries of the UK.)
A Certificate of Lawful Use would be awarded if applied for when one can demonstrate that someone has lived in a dwelling or other structure for at least ten years for a caravan or 4 years for anything else.
Basically, if the council has not issued an enforcement notice within that timeframe, they lose the right to do so and the occupation is henceforth lawful. The CLU, if you apply for it, confirms that fact, but is not necessary in order to live in the structure lawfully.
In order to get to the point where occupation is lawful and one has or could have a CLU awarded, one would need to construct / site the abode and live in it unlawfully for 4 or 10 years as appropriate. If someone reported you to the Planning Office during that time, you would probably get a Planning Contravention Notice initially, which could progress to a Planning Enforcement Notice if the planners are not satisfied with your responses. You would then be given usually 28 days notice to remove the dwelling (probably) and certainly to stop living in it. There is however, as far as I am aware, no penalty for having erected it or for occupying it unlawfully up to the point of receiving a PEN.
Note that if you were to apply for a CLU, it is incumbent upon the planners to disprove your evidence of continuous occupation for the relevant number of years. The only other reason they can have to not award the CLU, as far as I am aware, is if the applicant has behaved fraudulently - one example often given being having applied for and been granted permission to build an agricultural building and then having built a dwelling that looks like a hay barn, but internally is a fully equipped house.