I try to use the bgpdump shared library to read routeview's MRT format file. In the output, I found the following AS path:
1299 9318 38091 38091 38091 38091 38091 18313
The are many of them and this is only one example.
My question is why the ASN 38091 appears several times? Is it some kind of error? If it is not, why does it happen?
You are not seeing an error; the practice of adding an AS number multiple times is called AS Path Prepending (see "Traffic Engineering via Prepending").
One of the criteria that eBGP uses in its best-path selection algorithm is AS-Path-length. In many cases, BGP selects a path paths based on the shortest AS path, therefore AS Path prepending makes those announcements less preferred than announcements that were not prepended.
Some multi-homed eBGP autonomous systems use AS path prepending for traffic-engineering.
As an FYI, this is a short summary of the Cisco IOS BGP Path Selection algorithm (summarized from the hyperlink above)...
network
oraggregate
BGP subcommand, or through redistribution from an IGP like OSPF or ISIS.